package team.lourd.network.system.own.domain.netel;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.List;

@NoArgsConstructor
@Data
@Document("ne_flow_chart")
@Getter
@Setter
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
public class NEFlowChart {
    private String id;

    private List<Cells> cells;

    @NoArgsConstructor
    @Data
    public static class Cells {
        /**
         * type : standard.Ellipse
         * position : {"x":360,"y":160}
         * size : {"width":50,"height":50}
         * angle : 0
         * id : aa324b84-76ff-4415-ba91-e26abb1b6c36
         * z : 1
         * attrs : {"body":{"stroke":"#feb663","fill":"transparent","width":50,"height":30,"strokeDasharray":"10,5"},"label":{"fontSize":11,"fill":"#c6c7e2","text":"开始","fontFamily":"Roboto Condensed","fontWeight":"Normal","strokeWidth":0},"root":{"dataTooltipPosition":"left","dataTooltipPositionSelector":".joint-stencil"}}
         * router : {"name":"normal"}
         * connector : {"name":"rounded"}
         * labels : []
         * source : {"id":"aa324b84-76ff-4415-ba91-e26abb1b6c36"}
         * target : {"id":"f939ec8d-a3d3-42ba-957d-f9488e4b0156"}
         */

        private String type;
        private Position position;
        private Size size;
        private int angle;
        @Field("key")
        private String id;
        private int z;
        private Attrs attrs;
        private Router router;
        private Connector connector;
        private Source source;
        private Target target;
//        private Map<String,Object> source;
//        private Map<String,Object> target;
        private List<?> labels;
        private String condition;
        private String processExpression;

        @NoArgsConstructor
        @Data
        public static class Position {
            /**
             * x : 360
             * y : 160
             */

            private int x;
            private int y;
        }

        @NoArgsConstructor
        @Data
        public static class Size {
            /**
             * width : 50
             * height : 50
             */

            private int width;
            private int height;
        }

        @NoArgsConstructor
        @Data
        public static class Attrs {
            /**
             * body : {"stroke":"#feb663","fill":"transparent","width":50,"height":30,"strokeDasharray":"10,5"}
             * label : {"fontSize":11,"fill":"#c6c7e2","text":"开始","fontFamily":"Roboto Condensed","fontWeight":"Normal","strokeWidth":0}
             * root : {"dataTooltipPosition":"left","dataTooltipPositionSelector":".joint-stencil"}
             */

            private Body body;
            private Label label;
            private Root root;

            @NoArgsConstructor
            @Data
            public static class Body {
                /**
                 * stroke : #feb663
                 * fill : transparent
                 * width : 50
                 * height : 30
                 * strokeDasharray : 10,5
                 */

                private String stroke;
                private String fill;
                private int width;
                private int height;
                private String strokeDasharray;
            }

            @NoArgsConstructor
            @Data
            public static class Label {
                /**
                 * fontSize : 11
                 * fill : #c6c7e2
                 * text : 开始
                 * fontFamily : Roboto Condensed
                 * fontWeight : Normal
                 * strokeWidth : 0
                 */

                private int fontSize;
                private String fill;
                private String text;
                private String fontFamily;
                private String fontWeight;
                private int strokeWidth;
            }

            @NoArgsConstructor
            @Data
            public static class Root {
                /**
                 * dataTooltipPosition : left
                 * dataTooltipPositionSelector : .joint-stencil
                 */

                private String dataTooltipPosition;
                private String dataTooltipPositionSelector;
            }
        }

        @NoArgsConstructor
        @Data
        public static class Router {
            /**
             * name : normal
             */

            private String name;
        }

        @NoArgsConstructor
        @Data
        public static class Connector {
            /**
             * name : rounded
             */

            private String name;
        }

        @NoArgsConstructor
        @Data
        @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
        public static class Source {
            /**
             * id : aa324b84-76ff-4415-ba91-e26abb1b6c36
             */

            //@Id
            //@Field("_id")
            //private String _id;

            @Field("key")
            private String id;

        }

        @NoArgsConstructor
        @Data
        @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
        public static class Target {
            /**
             * id : f939ec8d-a3d3-42ba-957d-f9488e4b0156
             */
            @Field("key")
            private String id;

            //@Id
            //@Field("_id")
            //private String _id;
        }
    }
}
